$(document).ready(function () {
$("form").submit(function () {
    return false;
});
//var actFlg = "";
var VAL = {
    NORMAL: "0000000",
    EVT_USER: $("#userId").text(),
    T_FBPBISOPE: 'FBPBISOPE',
    T_FIPINQBOX: 'FIPINQBOX',
    T_FBPSWHPTH: "FBPSWHPTH",
    T_FIPINQSHT: "FIPINQSHT",
    DISABLED_ATTR: {
        'disabled': true
    },
    ENABLED_ATTR: {
        'disabled': false
    }
};
  var domObj = {

    buttons: {
        $query_btn: $("#query_btn"),
    },
    $gWeight    :  $("#gWeight"),
    $nWeight    :  $("#nWeight"),
    $NPrdouctId :  $("#NPrdouctId"),
    $radioNPr   :  $("#radioNPr"),
    $radioNBo   :  $("#radioNBo"),
    $WPrdouctId :  $("#WPrdouctId"),
    $radioWPr   :  $("#radioWPr"),
    $radioWBo   :  $("#radioWBo"),
 }
    var toolFunc = {
        print_func: function () {
          var gWeight = domObj.$gWeight.val();
            if (!gWeight) {
                showErrorDialog("", "毛重信息不能为空");
                return false;
            }
          var nWeight = domObj.$nWeight.val();
            if (!nWeight) {
                showErrorDialog("", "净重信息不能为空");
                return false;
            }
            if(domObj.$radioNPr.attr("checked") == "checked"){
                var prductId = domObj.$NPrdouctId.val();
                var typeA    = "P";
                var typeB    = "N";

            }
            if(domObj.$radioNBo.attr("checked") == "checked"){
                var prductId = domObj.$NPrdouctId.val();
                var typeA    = "B";
                var typeB    = "N";
            }
            if(domObj.$radioWPr.attr("checked") == "checked"){
                var prductId = domObj.$WPrdouctId.val();
                var typeA    = "P";
                var typeB    = "W";
            }
            if(domObj.$radioWBo.attr("checked") == "checked"){
                var prductId = domObj.$WPrdouctId.val();
                var typeA    = "B";
                var typeB    = "W";
            }
            iary = {
                prductId: prductId,
                typeA    : typeA,
                typeB    : typeB,
            }
            inObj = {
                trx_id: VAL.T_FIPINQBOX,
                action_flg: 'N',
                iary: [iary]
            };
            outObj = comTrxSubSendPostJson(inObj);
            if (outObj.rtn_code == VAL.NORMAL) {
                if(outObj.wo_id_fk.length==8){
                    var woIdFk = outObj.wo_id_fk;
                    outObj.wo_id_fk = woIdFk.slice(0,1)+ woIdFk.slice(2,8)
                }
                printBtnfunc(outObj.mdl_id_fk,outObj.mdl_desc,outObj.wo_id_fk,
                    outObj.prd_qty,nWeight,gWeight,outObj.box_id);
            }
        }
    }
    $(":radio").click(function(){
        if(domObj.$radioNPr.attr("checked") == "checked"){
            domObj.$WPrdouctId.val("");
            domObj.$NPrdouctId.attr(VAL.ENABLED_ATTR);
            domObj.$WPrdouctId.attr(VAL.DISABLED_ATTR);
        }
        if(domObj.$radioNBo.attr("checked") == "checked"){
            domObj.$WPrdouctId.val("");
            domObj.$NPrdouctId.attr(VAL.ENABLED_ATTR);
            domObj.$WPrdouctId.attr(VAL.DISABLED_ATTR);
        }
        if(domObj.$radioWPr.attr("checked") == "checked"){
            domObj.$NPrdouctId.val("");
            domObj.$NPrdouctId.attr(VAL.DISABLED_ATTR);
            domObj.$WPrdouctId.attr(VAL.ENABLED_ATTR);
        }
        if(domObj.$radioWBo.attr("checked") == "checked"){
            domObj.$NPrdouctId.val("");
            domObj.$NPrdouctId.attr(VAL.DISABLED_ATTR);
            domObj.$WPrdouctId.attr(VAL.ENABLED_ATTR);
        }
    });
    domObj.$NPrdouctId.keydown(function(event){
        if(event.keyCode==13) {
            toolFunc.print_func();
        }
    });
    domObj.$WPrdouctId.keydown(function(event){
        if(event.keyCode==13) {
            toolFunc.print_func();
        }
    });
    domObj.buttons.$query_btn.bind('click', toolFunc.print_func);
    var initializationFunc = function () {

    }
    initializationFunc();
    //enter
   /* document.onkeydown=function(event){
        var e = event || window.event || arguments.callee.caller.arguments[0];
        if(e && e.keyCode==13){ // 按 enter
            $('.bootbox').modal("hide");
        }
    }*/
});



